home *** CD-ROM | disk | FTP | other *** search
/ Dr. Windows 3 / dr win3.zip / dr win3 / PROGRAMR / OLE2BOOK.ZIP / CHAP08.ZIP / CHAP08 / PATRON / PATRON.H < prev    next >
C/C++ Source or Header  |  1993-06-07  |  6KB  |  223 lines

  1. /*
  2.  * PATRON.H
  3.  * Modifications for Chapter 8
  4.  *
  5.  * Single include file that pulls in everything needed for other source
  6.  * files in the application.
  7.  *
  8.  * Copyright (c)1993 Microsoft Corporation, All Rights Reserved
  9.  *
  10.  * Kraig Brockschmidt, Software Design Engineer
  11.  * Microsoft Systems Developer Relations
  12.  *
  13.  * Internet  :  kraigb@microsoft.com
  14.  * Compuserve:  >INTERNET:kraigb@microsoft.com
  15.  */
  16.  
  17.  
  18. #ifndef _PATRON_H_
  19. #define _PATRON_H_
  20.  
  21. #include <windows.h>
  22.  
  23. #include <ole2.h>
  24. #include <ole2ver.h>
  25. #include <ole2ui.h>
  26. #include <bookguid.h>
  27.  
  28. extern "C"
  29.     {
  30.     #include <commdlg.h>
  31.     #include <print.h>
  32.     }
  33.  
  34. #include <classlib.h>
  35. #include "resource.h"
  36.  
  37. //Get editor window information
  38. #include "pages.h"
  39.  
  40. //PATRON.CPP:  Frame object that creates a main window
  41.  
  42. class __far CPatronFrame : public CFrame
  43.     {
  44.     private:
  45.         BOOL            m_fInitialized;     //OleInitialize worked
  46.  
  47.     protected:
  48.         //Overridable for creating a CPatronClient
  49.         virtual LPCClient CreateCClient(void);
  50.  
  51.         virtual BOOL      FRegisterAllClasses(void);
  52.         virtual UINT      CreateGizmos(void);
  53.         virtual LRESULT   OnCommand(HWND, WPARAM, LPARAM);
  54.  
  55.     public:
  56.         CPatronFrame(HINSTANCE, HINSTANCE, LPSTR, int);
  57.         virtual ~CPatronFrame(void);
  58.  
  59.         //Overrides
  60.         BOOL FInit(LPFRAMEINIT);
  61.  
  62.         virtual void     UpdateMenus(HMENU, UINT);
  63.         virtual void     UpdateGizmos(void);
  64.  
  65.     };
  66.  
  67.  
  68. typedef CPatronFrame FAR * LPCPatronFrame;
  69.  
  70.  
  71.  
  72.  
  73.  
  74. //CLIENT.CPP
  75.  
  76. /*
  77.  * The only reason we have a derived class here is to override
  78.  * CreateCDocument so we can create our own type as well as
  79.  * overriding NewDocument to perform one other piece of work once the
  80.  * document's been created.
  81.  */
  82.  
  83. class __far CPatronClient : public CClient
  84.     {
  85.     protected:
  86.         //Overridable for creating a new CDocument
  87.         virtual LPCDocument CreateCDocument();
  88.  
  89.     public:
  90.         CPatronClient(HINSTANCE);
  91.         virtual ~CPatronClient(void);
  92.     };
  93.  
  94. typedef CPatronClient FAR * LPCPatronClient;
  95.  
  96.  
  97.  
  98. //DOCUMENT.CPP
  99.  
  100. //Constant ID for the pages window that lives in a document window
  101. #define ID_PAGES            723
  102.  
  103.  
  104. class __far CPatronDoc : public CDocument
  105.     {
  106.     //CHAPTER8MOD
  107.     //These need access to FQueryPasteFromData, FPasteFromData
  108.     friend class CDropTarget;
  109.     friend class CDropSource;
  110.     //End CHAPTER8MOD
  111.  
  112.     protected:
  113.         LONG            m_lVer;         //Loaded data version
  114.         LPCPages        m_pPG;          //Pages window in us.
  115.         LPSTORAGE       m_pIStorage;    //Root storage for document.
  116.         BOOL            m_fPrintSetup;  //Enable printer setup if no tenants.
  117.  
  118.         //CHAPTER8MOD
  119.         class CDropTarget FAR *m_pDropTarget;  //Registered target.
  120.         //End CHAPTER8MOD
  121.  
  122.     protected:
  123.         virtual BOOL    FMessageHook(HWND, UINT, WPARAM, LPARAM, LRESULT FAR *);
  124.  
  125.         BOOL            FQueryPasteFromData(LPDATAOBJECT, LPFORMATETC, LPTENANTTYPE);
  126.         BOOL            FPasteFromData(LPDATAOBJECT, LPFORMATETC, TENANTTYPE
  127.                             , LPPATRONOBJECT, DWORD);
  128.  
  129.     public:
  130.         CPatronDoc(HINSTANCE);
  131.         virtual ~CPatronDoc(void);
  132.  
  133.         virtual BOOL     FInit(LPDOCUMENTINIT);
  134.         virtual void     Clear(void);
  135.  
  136.         virtual BOOL     FDirtyGet(void);
  137.         virtual void     Delete(void);
  138.         virtual BOOL     FQueryPrinterSetup(void);
  139.         virtual BOOL     FQueryObjectSelected(HMENU);
  140.  
  141.         virtual UINT     ULoad(BOOL, LPSTR);
  142.         virtual UINT     USave(UINT, LPSTR);
  143.  
  144.         virtual BOOL     Print(HWND);
  145.         virtual UINT     PrinterSetup(HWND, BOOL);
  146.  
  147.         virtual BOOL     FClip(HWND, BOOL);
  148.         virtual BOOL     FQueryPaste(void);
  149.         virtual BOOL     FPaste(HWND);
  150.         virtual BOOL     FPasteSpecial(HWND);
  151.  
  152.         virtual UINT     NewPage(void);
  153.         virtual UINT     DeletePage(void);
  154.         virtual UINT     NextPage(void);
  155.         virtual UINT     PreviousPage(void);
  156.         virtual UINT     FirstPage(void);
  157.         virtual UINT     LastPage(void);
  158.     };
  159.  
  160. typedef CPatronDoc FAR * LPCPatronDoc;
  161.  
  162.  
  163. //CHAPTER8MOD
  164. //Drag-drop interfaces we need in the document
  165.  
  166. class __far CDropTarget : public IDropTarget
  167.     {
  168.     protected:
  169.         ULONG               m_cRef;      //Interface reference count.
  170.         LPCPatronDoc        m_pDoc;      //Back pointer to the document
  171.  
  172.         LPDATAOBJECT        m_pIDataObject;  //Data object from DragEnter
  173.         BOOL                m_fPendingRepaint;
  174.         POINTL              m_ptPick;        //Pick-up offsets
  175.         POINTL              m_ptLast;        //Last drag point
  176.         SIZEL               m_szl;           //Object size
  177.         BOOL                m_fFeedback;     //Draw feedback?
  178.         FORMATETC           m_fe;            //Real dropping format.
  179.  
  180.     public:
  181.         CDropTarget(LPCPatronDoc);
  182.         ~CDropTarget(void);
  183.  
  184.         //IDropTarget interface members
  185.         STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *);
  186.         STDMETHODIMP_(ULONG) AddRef(void);
  187.         STDMETHODIMP_(ULONG) Release(void);
  188.  
  189.         STDMETHODIMP DragEnter(LPDATAOBJECT, DWORD, POINTL, LPDWORD);
  190.         STDMETHODIMP DragOver(DWORD, POINTL, LPDWORD);
  191.         STDMETHODIMP DragLeave(void);
  192.         STDMETHODIMP Drop(LPDATAOBJECT, DWORD, POINTL, LPDWORD);
  193.     };
  194.  
  195.  
  196. typedef CDropTarget FAR * LPCDropTarget;
  197.  
  198. class __far CDropSource : public IDropSource
  199.     {
  200.     protected:
  201.         ULONG               m_cRef;      //Interface reference count.
  202.  
  203.     public:
  204.         CDropSource(void);
  205.         ~CDropSource(void);
  206.  
  207.         //IDropSource interface members
  208.         STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *);
  209.         STDMETHODIMP_(ULONG) AddRef(void);
  210.         STDMETHODIMP_(ULONG) Release(void);
  211.  
  212.         STDMETHODIMP QueryContinueDrag(BOOL, DWORD);
  213.         STDMETHODIMP GiveFeedback(DWORD);
  214.     };
  215.  
  216.  
  217. typedef CDropSource FAR * LPCDropSource;
  218.  
  219. //End CHAPTER8MOD
  220.  
  221.  
  222. #endif //_PATRON_H_
  223.